﻿using System;
using UnityEngine;
using UnityEngine.Serialization;

namespace MarchingSquares
{
    [Serializable]
    public struct VoxelData
    {
        public Vector3 position;
        public float value;
        [NonSerialized] public int type;
        [NonSerialized] public int neighborType;
    }

    public struct CellData
    {
        public Vector3 a;
        public Vector3 b;
        public Vector3 c;
        public Vector3 d;
    }

    public abstract class Marching
    {
        public Mesh mesh;
        protected VoxelChunk _voxelChunk;

        public abstract void Initialize(Material voxelMaterial, Vector3 chunkPosition, int chunkResolution,
            VoxelChunk voxelChunk);

        public abstract void Triangulate(ref VoxelData[] voxelData, float isoLevel, bool useUVMapping = false,
            bool useInterpolation = true, int[] cellsType = null);

        public abstract void Clear();
        public abstract void Destroy();
    }
}